package com.sys.orders.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import com.sys.common.pojo.BasePojo;
import com.sys.users.pojo.ACart;
import com.sys.users.pojo.AUsers;

/**
 * ~POJO(Plain Object java Object:(JavaBean) 得一个属性 得提供读写器 得有一个无参的构造函数
 * 
 * ~类名和表名一样 ~属性名和列名一样 ~对象和表里面的记录一样 ~表中间的下划线去掉
 * 
 * ~列模式:alt + shift + a; ~属性:四类八种默认值是0,包装类型默认是null;
 * 
 * @author 
 */
public class AOrders extends BasePojo<AOrders>
{
	private int id;
	private int usersId;
	private String receName;
	private String recePhone;
	private String receAddress;
	private double totalPrice;
	private double discount ; 
	private double dealAmount;
	private String content;
	private byte payType ; 
	private byte logisticsType ; 
	private String logisticsSn ; 
	private byte status;
	private Date createTime;
	private Date updateTime;
	private Date pubTime;
	private Date payTime;

	/*--字符串表示--*/
	private String statusStr;
	private String payTypeStr ; 
	private String logisticsTypeStr ;
	/*--关联对象表示--*/
	private AUsers users;
	
	private List<ACart> cartList = new ArrayList<ACart>();
	
	/* 存储所有状态的容器 */
	private Map<String, String> enumsMap = new TreeMap<String, String>();

	/**
	 * 获取此表相关的所有枚举值
	 * 
	 * @return 键为枚举的变量名+枚举的值; 值为枚举的名字 如:key:STATUS_ENABLE-1,值:启用
	 */
	public Map<String, String> getEnumsMap()
	{
		// 根据状态值获取字符串描述
		AOrdersEnum[] enums = AOrdersEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AOrdersEnum enumTemp = enums[i];
			String key = enumTemp.toString();
			enumsMap.put(key + "-" + enumTemp.getStatus() + "", enumTemp.getName());
		}
		return enumsMap;
	}

	/**
	 * 获取状态的字符串描述
	 * 
	 * @return 此状态对应的字符串描述
	 */
	public String getStatusStr()
	{
		// 根据状态值获取字符串描述
		AOrdersEnum[] enums = AOrdersEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AOrdersEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("STATUS_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getStatus())
				{
					this.statusStr = enumTemp.getName();
					break;
				}
			}
		}
		return statusStr;
	}
	
	public String getPayTypeStr() {
		if(this.getStatus() <= AOrdersEnum.STATUS_YQR.getStatus()) {
			return "" ; 
		}
		// 根据状态值获取字符串描述
		AOrdersEnum[] enums = AOrdersEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AOrdersEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("PAYTYPE_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getPayType())
				{
					this.payTypeStr = enumTemp.getName();
					break;
				}
			}
		}
		return payTypeStr;
	}
	
	public String getLogisticsTypeStr() {
		// 根据状态值获取字符串描述
		AOrdersEnum[] enums = AOrdersEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AOrdersEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("LOGISTICSTYPE_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getLogisticsType())
				{
					this.logisticsTypeStr = enumTemp.getName();
					break;
				}
			}
		}
		return logisticsTypeStr;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getUsersId()
	{
		return usersId;
	}

	public void setUsersId(int usersId)
	{
		this.usersId = usersId;
	}

	public String getReceName()
	{
		return receName;
	}

	public void setReceName(String receName)
	{
		this.receName = receName;
	}

	public String getRecePhone()
	{
		return recePhone;
	}

	public void setRecePhone(String recePhone)
	{
		this.recePhone = recePhone;
	}

	public String getReceAddress()
	{
		return receAddress;
	}

	public void setReceAddress(String receAddress)
	{
		this.receAddress = receAddress;
	}

	public double getTotalPrice()
	{
		return totalPrice;
	}

	public void setTotalPrice(double totalPrice)
	{
		this.totalPrice = totalPrice;
	}

	public double getDealAmount()
	{
		return dealAmount;
	}

	public void setDealAmount(double dealAmount)
	{
		this.dealAmount = dealAmount;
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getPubTime()
	{
		return pubTime;
	}

	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}

	public Date getPayTime()
	{
		return payTime;
	}

	public void setPayTime(Date payTime)
	{
		this.payTime = payTime;
	}

	public AUsers getUsers()
	{
		return users;
	}

	public void setUsers(AUsers users)
	{
		this.users = users;
	}

	public List<ACart> getCartList()
	{
		return cartList;
	}

	public void setCartList(List<ACart> cartList)
	{
		this.cartList = cartList;
	}

	public double getDiscount()
	{
		return discount;
	}

	public void setDiscount(double discount)
	{
		this.discount = discount;
	}

	public byte getPayType() {
		return payType;
	}

	public void setPayType(byte payType) {
		this.payType = payType;
	}

	public byte getLogisticsType() {
		return logisticsType;
	}

	public void setLogisticsType(byte logisticsType) {
		this.logisticsType = logisticsType;
	}

	public String getLogisticsSn() {
		return logisticsSn;
	}

	public void setLogisticsSn(String logisticsSn) {
		this.logisticsSn = logisticsSn;
	}

	public void setStatusStr(String statusStr) {
		this.statusStr = statusStr;
	}
}
